public class GuidScrubberTests
{
    #region NamedGuidGlobal

    [ModuleInitializer]
    public static void Init() => VerifierSettings.AddNamedGuid(new("c8eeaf99-d5c4-4341-8543-4597c3fd40c9"), "guidName");

    #endregion

    [Theory]
    [InlineData("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "no match")]
    [InlineData("aaaaaaaaaaaaaaaaaaaaaaaa", "no match short")]
    [InlineData("173535ae-995b-4cc6-a74e-8cd4be57039c", "simple")]
    [InlineData("173535ae-995b-4cc6-a74e-8cd4be57039c 173535ae-995b-4cc6-a74e-8cd4be57039d", "simple-multiple")]
    [InlineData("173535ae-995b-4cc6-a74e-8cd4be57039c 173535ae-995b-4cc6-a74e-8cd4be57039c", "simple-duplicate")]
    [InlineData("{173535ae-995b-4cc6-a74e-8cd4be57039c}", "curly")]
    [InlineData("{173535ae-995b-4cc6-a74e-8cd4be57039c} {173535ae-995b-4cc6-a74e-8cd4be57039d}", "curly-multiple")]
    [InlineData("{173535ae-995b-4cc6-a74e-8cd4be57039c} {173535ae-995b-4cc6-a74e-8cd4be57039c}", "curly-duplicate")]
    [InlineData("{173535ae-995b-4cc6-a74e-8cd4be57039c", "start-curly")]
    [InlineData("173535ae-995b-4cc6-a74e-8cd4be57039c}", "end-curly")]
    [InlineData("-173535ae-995b-4cc6-a74e-8cd4be57039c-", "dash")]
    [InlineData("-173535ae-995b-4cc6-a74e-8cd4be57039c- -173535ae-995b-4cc6-a74e-8cd4be57039d-", "dash-multiple")]
    [InlineData("-173535ae-995b-4cc6-a74e-8cd4be57039c- -173535ae-995b-4cc6-a74e-8cd4be57039c-", "dash-duplicate")]
    [InlineData("-173535ae-995b-4cc6-a74e-8cd4be57039c", "start-dash")]
    [InlineData("173535ae-995b-4cc6-a74e-8cd4be57039c-", "end-dash")]
    [InlineData("/173535ae-995b-4cc6-a74e-8cd4be57039c/", "fslash")]
    [InlineData("/173535ae-995b-4cc6-a74e-8cd4be57039c", "start-fslash")]
    [InlineData("173535ae-995b-4cc6-a74e-8cd4be57039c/", "end-fslash")]
    [InlineData("\\173535ae-995b-4cc6-a74e-8cd4be57039c\\}", "bslash")]
    [InlineData("\\173535ae-995b-4cc6-a74e-8cd4be57039c", "start-bslash")]
    [InlineData("173535ae-995b-4cc6-a74e-8cd4be57039c\\", "end-bslash")]
    [InlineData("[173535ae-995b-4cc6-a74e-8cd4be57039c]", "square")]
    [InlineData("[173535ae-995b-4cc6-a74e-8cd4be57039c] [173535ae-995b-4cc6-a74e-8cd4be57039d]", "square-multiple")]
    [InlineData("[173535ae-995b-4cc6-a74e-8cd4be57039c] [173535ae-995b-4cc6-a74e-8cd4be57039c]", "square-duplicate")]
    [InlineData("[173535ae-995b-4cc6-a74e-8cd4be57039c", "start-square")]
    [InlineData("173535ae-995b-4cc6-a74e-8cd4be57039c]", "end-square")]
    [InlineData("a173535ae-995b-4cc6-a74e-8cd4be57039ca", "letters")]
    [InlineData("a173535ae-995b-4cc6-a74e-8cd4be57039c", "start-letters")]
    [InlineData("173535ae-995b-4cc6-a74e-8cd4be57039ca", "end-letters")]
    [InlineData("1173535ae-995b-4cc6-a74e-8cd4be57039c1", "numbers")]
    [InlineData("1173535ae-995b-4cc6-a74e-8cd4be57039c", "start-numbers")]
    [InlineData("173535ae-995b-4cc6-a74e-8cd4be57039c1", "end-numbers")]
    public async Task Run(string guid, string name)
    {
        using var counter = Counter.Start();
        var builder = new StringBuilder(guid);
        GuidScrubber.ReplaceGuids(builder, counter);
        await Verify(builder)
            .DontScrubGuids()
            .UseTextForParameters(name);
    }

    [Theory]
    [InlineData("c8eeaf99-d5c4-4341-8543-4597c3fd40c9", "named")]
    [InlineData("c8eeaf99-d5c4-4341-8543-4597c3fd40d9", "instanceNamed")]
    public Task NamedGuids(string guid, string name) =>
        Verify(
                new
                {
                    value = new Guid(guid)
                })
            .AddNamedGuid(new("c8eeaf99-d5c4-4341-8543-4597c3fd40d9"), "instanceNamed")
            .UseTextForParameters(name);

    #region NamedGuidInstance

    [Fact]
    public Task NamedGuidInstance()
    {
        var settings = new VerifySettings();
        var guid = new Guid("c8eeaf99-d5c4-4341-8543-4597c3fd40d9");
        settings.AddNamedGuid(guid, "instanceNamed");
        return Verify(
            new
            {
                value = guid
            },
            settings);
    }

    #endregion

    //top level should not scrub
    [Fact]
    public Task NamedGuidTopLevelInstance()
    {
        var settings = new VerifySettings();
        var guid = new Guid("c8eeaf99-d5c4-4341-8543-4597c3fd40d9");
        settings.AddNamedGuid(guid, "instanceNamed");
        return Verify(guid, settings);
    }

    [Fact]
    public void MultipleChunks()
    {
        var builder = new StringBuilder(capacity: 8, maxCapacity: int.MaxValue);
        builder.Append("[2e6bddf7-fcf7-4b09-bb6f-a7948e1eecf3]");
        builder.Append("[c2eeaf99-d5c4-4341-8543-4597c3fd40d9]");
        using var counter = Counter.Start();
        GuidScrubber.ReplaceGuids(builder, counter);
        Assert.Equal("[Guid_1][Guid_2]", builder.ToString());
    }

    #region NamedGuidFluent

    [Fact]
    public Task NamedGuidFluent()
    {
        var guid = new Guid("c8eeaf99-d5c4-4341-8543-4597c3fd40d9");
        return Verify(
                new
                {
                    value = guid
                })
            .AddNamedGuid(guid, "instanceNamed");
    }

    #endregion

    #region InferredNamedGuidFluent

    [Fact]
    public Task InferredNamedGuidFluent()
    {
        var namedGuid = new Guid("c8eeaf99-d5c4-4341-8543-4597c3fd40d9");
        return Verify(
                new
                {
                    value = namedGuid
                })
            .AddNamedGuid(namedGuid);
    }

    #endregion

    [Fact]
    public Task NamedGuidTopLevelFluent()
    {
        var guid = new Guid("c8eeaf99-d5c4-4341-8543-4597c3fd40d9");
        return Verify(guid)
            .AddNamedGuid(guid, "instanceNamed");
    }

    [Fact]
    public Task NamedGuidTopLevelGlobal() =>
        Verify(new Guid("c8eeaf99-d5c4-4341-8543-4597c3fd40c9"));
}